package com.project.livetv.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.project.livetv.R;
import com.project.livetv.bean.MyMessage;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/05/10/0010.
 * <p/>
 * 信息发送过来的消息
 */
public class MyAdapterForMainTv extends MyBaseAdapterForList<MyMessage> {


    public MyAdapterForMainTv(List<MyMessage> mDatas, Context mContext) {
        super(mDatas, mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_maintv_info, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvItemNick.setText(mDatas.get(position).getNick());
        holder.tvItemInfo.setText(mDatas.get(position).getMessage());
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.tv_item_nick)
        TextView tvItemNick;
        @Bind(R.id.tv_item_info)
        TextView tvItemInfo;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
